const autoprefixer = require('autoprefixer');
const pxtorem = require('postcss-pxtorem');

module.exports = ({
    file
}) => {
    let rootValue
    // vant 37.5 [link](https://github.com/youzan/vant/issues/1181)
    if (file && file.dirname && file.dirname.indexOf('vant') > -1) {
        rootValue = 37.5
    } else {
        rootValue = 75
    }

    return {
        plugins: [
            autoprefixer({
                overrideBrowserslist: ['Android >= 4.0', 'iOS >= 8']
            }),
            pxtorem({
                rootValue: rootValue,
                propList: ['*'],
                // 过滤掉.am-开头的class，不进行rem转换
                selectorBlackList: ['.xxx-'], 
                minPixelValue: 2
            })
        ]
    };
};